import java.io.*;
class  CopyText2
{
	public static void main(String[] args) 
	{
		FileReader fr = null;
		FileWriter fw = null;

		try
		{
			fr = new FileReader("RuntimeDemo.java");
			fw = new FileWriter("c.txt");

			char[] chs = new char[1024];

			int len = 0;

			while((len=fr.read(chs))!=-1)
			{
				fw.write(chs,0,len);
			}

		}
		catch (IOException e)
		{
			System.out.println(e.toString());
		}
		finally
		{
			try
			{
				if(fw!=null)
					fw.close();
			}
			catch (IOException e)
			{
				System.out.println(e.toString());
			}
			try
			{
				if(fr!=null)
					fr.close();
			}
			catch (IOException e)
			{
				System.out.println(e.toString());
			}
		}
	}
}
